package com.dearbinge.data.dao;

import com.dearbinge.data.pojo.orderDetailTable.OrderDetailTable;

import org.apache.ibatis.annotations.Param;
import org.mapstruct.Mapper;

import java.util.List;

@Mapper
public interface OrderDetailTableMapper {

    Integer update(OrderDetailTable orderDetailTable);

    Integer insert(OrderDetailTable orderDetailTable);

    Integer delete(Integer id);

    OrderDetailTable getById(String orderId);


    /**
     * 根据 订单id和规格id查询
     * @param orderId 订单id
     * @param commoditySpecId 规格id
     * @return 订单详情DO
     */
    OrderDetailTable getByOrderIdAndSpecId(@Param("orderId") String orderId, @Param("commoditySpecId")String commoditySpecId);


    /**
     * 最近三十天销量
     * @param commodityId 商品id
     * @return 销量
     */
    Integer countByCommodityId(String commodityId);

    /**
     * 更新评论状态
     * @param commentStatus 评论状态
     * @param id id
     * @return 影响行数
     */
    Integer updateCommentStatus(@Param("commentStatus") Integer commentStatus,@Param("id") Integer id);

    /**
     * 根据订单id查询
     * @param orderId 订单id
     * @return 订单商品集
     */
    List<OrderDetailTable> listByOrderId(Integer orderId);

    Integer salesVolume(String commodityId);
}
